import {
    RoleParams,
    RoleListGetResultModel,
    RolePageParams,
    RolePageListGetResultModel,
} from '../model/systemModel';
import {defHttp} from '/@/utils/http/axios';

enum Api {
    GetAllRoleList = '/role/options',
    RolePageListByPage = '/role',
    SetRoleStatus = '/role/status',
    DeleteRole = '/role',
    UpdateRole = '/role',
    CreateRole = '/role',
}

export const getAllRoleList = (params?: RoleParams) =>
    defHttp.get<RoleListGetResultModel>({url: Api.GetAllRoleList, params});


export const getRoleListByPage = (params?: RolePageParams) =>
    defHttp.get<RolePageListGetResultModel>({url: Api.RolePageListByPage, params});


export const setRoleStatus = (id: number, status: boolean) =>
    defHttp.put({url: Api.SetRoleStatus, data: {id, status}});

export const deleteRole = (id: number) =>
    defHttp.delete({url: `${Api.DeleteRole}/${id}`});

export const putRoleUpdate = (id: number, data) =>
    defHttp.put(({url: `${Api.UpdateRole}/${id}`, data}))


export const postRoleCreate = ( data) =>
    defHttp.post(({url: Api.CreateRole, data}))
